package tuan.filter;

import java.util.HashSet;
import java.util.Set;

import org.w3c.dom.Node;

public class AllowdTagFilter extends NodeFilter {
	Set<String> tagSet = new HashSet<String>();

	public AllowdTagFilter(String[] tagNames) throws Exception {
		if (tagNames == null) {
			throw new Exception("null arguments");
		}
		for (String s : tagNames) {
			tagSet.add(s);
		}
	}

	@Override
	protected boolean isValid(Node node) {
		if (tagSet.contains(node.getNodeName())) {
			return true;
		} else {
			return false;
		}
	}

}
